home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / CHARS.SWG / 0009_Reverse EGA-VGA Fonts.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-26  |  3KB  |  118 lines

  1. program Reverse;
  2.  
  3. {
  4.   Sample program demonstrating manipulation of the VGA (EGA?)
  5.   alphanumeric character set using the 80x25 character mode.
  6.  
  7.   The only thing this program does is to copy the current character
  8.   set from the video adapter, and restore it in such a way that all
  9.   the characters appear upside-down.  To restore the characters,
  10.   simply run the program again.  Not that this is a terribly useful
  11.   thing to do, mind you...
  12.  
  13.   NOTE: This has not been tested on monochrome monitors or in
  14.         other video modes.
  15.  
  16.   Written using Borland Pascal 7.0.
  17.  
  18.   For more information on character sets for other video modes and
  19.   a whole bunch of good stuff on the EGA & VGA in general, you will
  20.   want the following book:
  21.  
  22.    Title     - "Programmer's Guide to PC & PS/2 Video Systems"
  23.    Author    - Richard Wilton, 1987
  24.    Publisher - Microsoft Press
  25.                16011 NE 36th Way
  26.                Box 97017
  27.                Redmond, Washington  98073-9717
  28. }
  29.  
  30.   var
  31.     I, J: integer;
  32.     CBuf: array [0..8191] of byte; { Buffer for original character map }
  33.  
  34.  
  35.   procedure CharGenModeOn;
  36.  
  37.   { I'm sorry that there is no explanation here, but I did this a while
  38.     ago and I don't have the reference with me right now.   }
  39.  
  40.     begin
  41.       asm
  42.         cli
  43.         mov       dx,03C4h
  44.         mov       ax,0100h
  45.         out       dx,ax
  46.         mov       ax,0402h
  47.         out       dx,ax
  48.         mov       ax,0704h
  49.         out       dx,ax
  50.         mov       ax,0300h
  51.         out       dx,ax
  52.         sti
  53.         mov       dl,0CEh
  54.         mov       ax,0204h
  55.         out       dx,ax
  56.         mov       ax,0005h
  57.         out       dx,ax
  58.         mov       ax,0006h
  59.         out       dx,ax
  60.      end;
  61.    end;
  62.  
  63.  
  64.   procedure CharGenModeOff;
  65.  
  66.     begin
  67.       asm
  68.         cli
  69.         mov       dx,03C4h
  70.         mov       ax,0100h
  71.         out       dx,ax
  72.         mov       ax,0302h
  73.         out       dx,ax
  74.         mov       ax,0304h
  75.         out       dx,ax
  76.         mov       ax,0300h
  77.         out       dx,ax
  78.         sti
  79.         mov       dl,0CEh
  80.         mov       ax,0004h
  81.         out       dx,ax
  82.         mov       ax,1005h
  83.         out       dx,ax
  84.         mov       ax,0E06h
  85.         out       dx,ax
  86.         mov       ah,0Fh
  87.         int       10h
  88.         cmp       al,7
  89.         jne       @skip
  90.         mov       ax,0806h
  91.         out       dx,ax
  92.       @skip:
  93.       end;
  94.     end;
  95.  
  96.  
  97.   begin
  98.     CharGenModeOn;  { Get access to character map }
  99.  
  100.     { Copy the current character map into the buffer }
  101.     move( mem[$A000: 0], CBuf, 8192 );
  102.  
  103.     { Restore the map, inverting the top 16 scan lines.
  104.  
  105.       Characters are stored in a 8x32 pixel matrix, allowing
  106.       for characters that are 32 scan lines high.  Each byte
  107.       in the buffer represents one scan line of a single
  108.       character.  In the 80x25 character mode only the first
  109.       16 scan lines are displayed, so we need to be a little
  110.       careful about what bytes are swapped. }
  111.  
  112.     for I := 0 to 255 do                { Each of the 256 characters }
  113.       for J := 0 to 15 do               { Top 16 scan lines of each }
  114.         mem[$a000:((I*32) + J)] := CBuf[(I*32) + (15 - J)];
  115.  
  116.     CharGenModeOff; { Restore normal video operations }
  117.   end.
  118.